#include<vector>
#include<iostream>
using namespace std;
int main(){
	int n,m,b,c,i,j,k;
	cin>>n>>m;
	vector<int>a[n];
	while(m--){
		cin>>b>>c;
		a[b-1].push_back(c);
	}
	for(i=0;i<n;++i){
		k=a[i].size();
		for(j=0;j<k;++j)
			cout<<a[i][j]<<" ";
		cout<<endl;
	}
	return 0;
}